package cn.itcast.controller;

import cn.itcast.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/buy")
public class BuyController {
    @Resource
    private UserService service;

    @RequestMapping("/addCart.do")
    @ResponseBody
    public Map<String,Object> addCart(Integer id){
        String result="null";
        Map<String,Object> maplist=new HashMap<>();
        Boolean flag =service.addcart(id);
        if(flag){
            result="1";
        }else{
            result="0";
        }
        maplist.put("result",result);
        return maplist;
    }
}
